<template>
  <div>
    <el-cascader
      v-model="details"
	  clearable
      ref="myCascader"
      :options="newArr"
      :props="{ value: 'id', label: 'name', children: 'sub',checkStrictly: checked }"
      placeholder="选择商品分类"
      style="width: 100%;"
      @change="handleChange"
      :size="size"
	  :disabled="disable"
    ></el-cascader>
  </div>
</template>

<script>
  import { getCategoryQuery } from '@/api/category'
  export default {
    props: {
      size: {
        type: String,
      },
	  disable:{
		 type:Boolean,
		 default () {
		 	return false
		 }
	  },
	  checked:{
		  type:Boolean,
		  default () {
		  	return false
		  }
	  }
    },
    data() {
      return {
        newArr: [],
        details: '',
      }
    },
    async created() {
      const res = await getCategoryQuery({
        ws_id: 1,
      })
      this.newArr = res.data
      // res.data.map((item) => {
      //   var obj = {}
      //   obj.children = []
      //   obj.value = item.id
      //   obj.label = item.name
      //   item.sub.map((res) => {
      //     obj.children.push({
      //       value: res.id,
      //       label: res.name,
      //       parent_id: res.parent_id,
      //       remarks: res.remarks,
      //       seq: res.seq,
      //       ws_id: res.ws_id,
      //     })
      //   })
      //   this.newArr.push(obj)
      // })
    },
    methods: {
      handleChange(event) {
        this.$emit('selectType', event)
      },
    },
  }
</script>
